
#include <BRender>
#include "member_BViewer.h"
#include "member_BHandler.h"
#include "member_BCamera.h"

using namespace BWE;

member_BViewer::member_BViewer(BViewer* viewer)
{
	boss = viewer;
}
member_BViewer::~member_BViewer()
{

}

void member_BViewer::paintHandler(BHandler* handler, BPainter& painter)
{
	if (!handler || !handler->enabled())
		return;
	handler_member(handler)->paint(painter);
	for (int i = 0; i < handler_member(handler)->children.size(); i++)
	{
		BHandler* child = handler_member(handler)->children[i];
		paintHandler(child, painter);
	}
}

void member_BViewer::slotCameraChanged(BObject* object)
{
	if (camera == object)
	{
		if (camera->pixelSizePolicy() == Policy_Dynamic)
		{
			const BRect& crect = boss->centerRect();
			camera->setPixelSize(crect.size());
			BReal aspect = (BReal)crect.width() / crect.height();
			camera->setAspect(aspect);
		}
		camera_member(camera)->refresh = true;
		boss->fresh();
	}
}
void member_BViewer::slotCameraFreshed(BObject* object)
{
	if (camera == object)
	{
		camera_member(camera)->refresh = true;
		boss->fresh();
	}
}
void member_BViewer::slotSceneFresh(BObject* object)
{
	if (camera)
	{
		camera_member(camera)->refresh = true;
		boss->fresh();
	}
}
